import path from 'path';
import resolve from '@rollup/plugin-node-resolve';
import alias from '@rollup/plugin-alias';
import { fileURLToPath } from 'url';

const _dirname = path.dirname(fileURLToPath(import.meta.url))

const customResolver = resolve({
    extensions: ['.mjs', '.js', '.jsx', '.json']
});
const projectRootDir = path.resolve(_dirname, './js/src/swda/');

export default {
    input: './js/src/swda/index.js',
    output: {
        file: './js/plugins/SWDA_Core.js',
        format: 'umd',
        sourcemap: true,
    },
    watch: {
        include: './js/src/swda/**'
    },
    plugins: [

        // 别名
        alias({
            entries: [
                { find: '@swda', replacement: path.resolve(projectRootDir) },
            ],
            customResolver
        }),
    ]
}